package yxy.cherry.battle.module;

import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;

public class PropertyData {



	Map<PropertyType, Long> properties = new HashMap<>();// 属性

	public PropertyData() {
	}


	public Map<PropertyType, Long> getProperties() {
		return properties;
	}

	public void setProperties(Map<PropertyType, Long> properties) {
		this.properties = properties;
	}
	public void setValue(PropertyType type, long value) {
		if (type == null) {
			return;
		}
		this.properties.put(type, value);
	}

	public long getValue(PropertyType type) {
		if (!this.properties.containsKey(type)) {
			return 0;
		}
		return this.properties.get(type);
	}

	public void addValue(PropertyType type, long value) {
		if (type == null) {
			return;
		}
		this.properties.put(type, getValue(type) + value);
	}

	public void addAllValue(PropertyData propertyData) {
		if (propertyData == null) {
			return;
		}
		for (Entry<PropertyType, Long> entry : propertyData.properties.entrySet()) {
			long value = getValue(entry.getKey());
			this.properties.put(entry.getKey(), entry.getValue() + value);
		}
	}

	/** 计算增幅数值 */
	static public long valueAdd(long value, long add) {
		Double dvalue = Double.valueOf(value);
		dvalue = dvalue * add / 10000;
		return dvalue.intValue();
	}

	@Override
	public String toString() {
		return properties.toString();
	}
}
